package com.ruoyi.zsyh.service.impl;

import java.util.List;
import java.util.ArrayList;
import com.ruoyi.common.core.domain.Ztree;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.zsyh.mapper.ZsyhAfterFactoryMenuMapper;
import com.ruoyi.zsyh.domain.ZsyhAfterFactoryMenu;
import com.ruoyi.zsyh.service.IZsyhAfterFactoryMenuService;
import com.ruoyi.common.core.text.Convert;

/**
 * 厂家售后菜单管理Service业务层处理
 * 
 * @author yuexl
 * @date 2022-09-26
 */
@Service
public class ZsyhAfterFactoryMenuServiceImpl implements IZsyhAfterFactoryMenuService 
{
    @Autowired
    private ZsyhAfterFactoryMenuMapper zsyhAfterFactoryMenuMapper;

    /**
     * 查询厂家售后菜单管理
     * 
     * @param id 厂家售后菜单管理ID
     * @return 厂家售后菜单管理
     */
    @Override
    public ZsyhAfterFactoryMenu selectZsyhAfterFactoryMenuById(String id)
    {
        return zsyhAfterFactoryMenuMapper.selectZsyhAfterFactoryMenuById(id);
    }

    /**
     * 查询厂家售后菜单管理列表
     * 
     * @param zsyhAfterFactoryMenu 厂家售后菜单管理
     * @return 厂家售后菜单管理
     */
    @Override
    public List<ZsyhAfterFactoryMenu> selectZsyhAfterFactoryMenuList(ZsyhAfterFactoryMenu zsyhAfterFactoryMenu)
    {
        return zsyhAfterFactoryMenuMapper.selectZsyhAfterFactoryMenuList(zsyhAfterFactoryMenu);
    }

    /**
     * 新增厂家售后菜单管理
     * 
     * @param zsyhAfterFactoryMenu 厂家售后菜单管理
     * @return 结果
     */
    @Override
    public int insertZsyhAfterFactoryMenu(ZsyhAfterFactoryMenu zsyhAfterFactoryMenu)
    {
        return zsyhAfterFactoryMenuMapper.insertZsyhAfterFactoryMenu(zsyhAfterFactoryMenu);
    }

    /**
     * 修改厂家售后菜单管理
     * 
     * @param zsyhAfterFactoryMenu 厂家售后菜单管理
     * @return 结果
     */
    @Override
    public int updateZsyhAfterFactoryMenu(ZsyhAfterFactoryMenu zsyhAfterFactoryMenu)
    {
        return zsyhAfterFactoryMenuMapper.updateZsyhAfterFactoryMenu(zsyhAfterFactoryMenu);
    }

    /**
     * 删除厂家售后菜单管理对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteZsyhAfterFactoryMenuByIds(String ids)
    {
        return zsyhAfterFactoryMenuMapper.deleteZsyhAfterFactoryMenuByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除厂家售后菜单管理信息
     * 
     * @param id 厂家售后菜单管理ID
     * @return 结果
     */
    @Override
    public int deleteZsyhAfterFactoryMenuById(String id)
    {
        return zsyhAfterFactoryMenuMapper.deleteZsyhAfterFactoryMenuById(id);
    }

    /**
     * 查询厂家售后菜单管理树列表
     * 
     * @return 所有厂家售后菜单管理信息
     */
    @Override
    public List<Ztree> selectZsyhAfterFactoryMenuTree()
    {
        List<ZsyhAfterFactoryMenu> zsyhAfterFactoryMenuList = zsyhAfterFactoryMenuMapper.selectZsyhAfterFactoryMenuList(new ZsyhAfterFactoryMenu());
        List<Ztree> ztrees = new ArrayList<Ztree>();
        for (ZsyhAfterFactoryMenu zsyhAfterFactoryMenu : zsyhAfterFactoryMenuList)
        {
            Ztree ztree = new Ztree();
            ztree.setId(Long.parseLong(zsyhAfterFactoryMenu.getId()));
            ztree.setpId(Long.parseLong(zsyhAfterFactoryMenu.getMenuParentid()));
            ztree.setName(zsyhAfterFactoryMenu.getMenuName());
            ztree.setTitle(zsyhAfterFactoryMenu.getMenuName());
            ztrees.add(ztree);
        }
        return ztrees;
    }
}
